﻿@using X.PagedList;
@using X.PagedList.Mvc.Core;
@using X.PagedList.Mvc.Common;
@using FwProject.PrePaymentInfo.Dto
@model ReceivableStatementOutputDto
@{
    Layout = null;
    int i = 0;
    if (Model.ReceivableStatementDetail.Count > 0)
    {
        if (Model.ReceivableStatementDetail.PageNumber != 1)
        {

            i = (Model.ReceivableStatementDetail.PageNumber - 1) * Model.ReceivableStatementDetail.PageSize;
        }
    }
    decimal? InitialReceivables = Model.InitialReceivables;


}
<div id="table_print" style="max-height:600px;overflow-y:scroll;">

    <table class="table table-bordered table-hover table-rowselected">
        <thead>
            <tr>
                <th>序号</th>
                <th>业务类型</th>
                <th>单据编号</th>
                <th>日期</th>
                <th>增加应收</th>
                <th>收回应收</th>
                <th>总优惠</th>
                <th>使用预收款</th>
                <th>期末应收款</th>
            </tr>
        </thead>
        <tbody>
            @if (Model.ReceivableStatementDetail.Count == 0)
            {
                <tr><td colspan="9" align="center">暂无数据</td></tr>
            }
            else
            {
                <tr>
                    <td></td>
                    <td>期初</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td>@Model.InitialReceivables</td>
                </tr>
                foreach (var item in Model.ReceivableStatementDetail)
                {
                    i++;
                    <tr>
                        <td>@i</td>
                        <td>@item.BusinessType</td>
                        <td>
                            @if (item.BusinessType == BusinessType.收据)
                            {
                                <a href="javascript:top.window.openTab(1112,'收据[@item.DocumentNumber]','/Receipt/SettlementDetails?id=@item.Id')">@item.DocumentNumber</a>
                            }
                            else
                            {
                                <a href="javascript:top.window.openTab(1455,'收款单[@item.DocumentNumber]','/Receipt/ReceiptDetail?id=@item.Id')">@item.DocumentNumber</a>
                            }
                        </td>
                        <td>@item.CreationTime.ToString("yyyy-MM-dd HH:mm:ss")</td>
                        <td>@item.AddReceivable</td>
                        <td>@item.TakeReceivable</td>
                        <td>@item.TotalDiscount</td>
                        <td>@item.UsePrePayment</td>
                        <td>@(InitialReceivables += item.FinalReceivables)</td>
                    </tr>
                }
                <tr>
                    <td></td>
                    <td>期末结存</td>
                    <td></td>
                    <td></td>
                    <td>@Model.FinalAddReceivable</td>
                    <td>@Model.FinalTakeReceivable</td>
                    <td>@Model.FinalTotalDiscount</td>
                    <td>@Model.FinalUsePrePayment</td>
                    <td>@Model.FinalReceivables</td>
                </tr>
            }
        </tbody>
    </table>
</div>
<div class="row pagedinfo">
    <div class="col-sm-5">
        共 @Model.ReceivableStatementDetail.TotalItemCount 条，
        <select class="form-control" id="pageSize" style="width:70px;display:initial">
            @for (int z = 10; z < 100; z = z + 10)
            {
                if (z == Model.ReceivableStatementDetail.PageSize)
                {
                    <option selected value="@z">@z</option>
                }
                else
                {
                    <option value="@z">@z</option>
                }
            }
        </select> &nbsp; 条/页 当前第 @Model.ReceivableStatementDetail.PageNumber/@Model.ReceivableStatementDetail.PageCount 页
    </div>
    <div class="col-sm-7">
        <input type="hidden" id="pageurl" value="&beginTime=@(Context.Request.Query["beginTime"])&endTime=@(Context.Request.Query["endTime"])" />
        @Html.PagedListPager(Model.ReceivableStatementDetail, page => Url.Action("ReceivableStatement", new { id = page, size = Context.Request.Query["size"], beginTime = Context.Request.Query["beginTime"], endTime = Context.Request.Query["endTime"] }), PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(new AjaxOptions() { AllowCache = false, HttpMethod = "Get", UpdateTargetId = "data_list", OnSuccess = "AjaxSuccessCallback", OnBegin = "AjaxBegin" }))
    </div>
</div>


